<title>邮箱</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">

<script type="text/javascript" src="#(assets)/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="#(assets)/js/app.js"></script>
<script type="text/javascript" src="#(assets)/js/layer/layer.js"></script>
<style> 
	*{margin:0;padding:0;}
	body{font-family:"Microsoft YaHei",Arial,Helvetica,sans-serif,"宋体";}
	li{list-style-type:none;}
	select,input{-webkit-appearance:none;border:0px;
		-webkit-tap-highlight-color: rgba(0, 0, 0, 0);   
	}
</style>
#@checkToken()
<body bgcolor="#f4f5f9" style="margin:0px;">
<div align=center>
	<div id="chosequestion"  align="left" style="clear:both;background:#fff;height:50px;line-height:50px;width:100%;margin-top:10px;"> 
		<input placeholder="请输入您的邮箱" id="email" style="padding-left:20px;height:50px;width:100%;font-size:16px;border:0px;"   />
		
	</div> 
	<div id="codes" style="clear:both;background:#fff;height:50px;width:100%;margin-top:10px;"> 
		<div align="left" style="float:left;line-height:50px;font-size:16px;">
			<input placeholder="请输入邮箱验证码" id="code" style="padding-left:20px;height:50px;width:80%;font-size:16px;border:0px;" type="tel"  />
		</div>
		<input id="getcode" value="获取邮箱验证码" style="text-align:center;color:#fa3048;float:right;width:100px;line-height:50px;font-size:14px;margin-right:20px;">
	</div>
	
	<div id="next" style="position:fixed;bottom:100px;width:90%;margin-left:5%;color:#fa3048;border:2px solid #fa3048;height:40px;line-height:40px;border-radius:8px;">确认提交</div>
	<script> 
	$(document).ready(function(){		
		
		$("#getcode").click(function(){
			var email = $("#email").val();
			if(email==""){
				layer.msg("邮箱不能为空！",{icon:2,time:1000}); 
			}else{
				$.getJSON("#(path)/user/setEmail?token=#(session.token??)&email="+email, function(datainfo) {
					if(datainfo.code=='success'){
						layer.msg(datainfo.msg,{icon:1,time:1000});
						waittime(getcode);
					}else{
						layer.msg(datainfo.msg,{icon:2,time:1000}); 
					}
				}); 
			}
		});

		$("#next").click(function(){
			var email = $("#email").val();
			var code = $("#code").val();
			$.getJSON("#(path)/user/setEmailAdvance?token=#(session.token??)&email="+email+"&code="+code, function(datainfo) {
				console.log(datainfo);
				if(datainfo.code=='success'){
					layer.msg(datainfo.msg,{icon:1,time:1000});
					window.location.href="#(path)/app/page/personal-account";
				}else{
					layer.msg(datainfo.msg,{icon:2,time:1000}); 
				}
			});
		});
		
		var wait=60;  
		function waittime(o) {  
			if (wait == 0) {  
				o.removeAttribute("disabled");            
				o.value="获取验证码";  
				wait = 60;  
			} else {  
				o.setAttribute("disabled", true);  
				o.value="(" + wait + ")";  
				wait--;  
				setTimeout(function() {  
					waittime(o)  
				},  
				1000)  
			}  
		}  
	});
	</script>
</body>